package com.web.my12306.service.impl;

import com.web.my12306.dao.IPrivilegeDao;
import com.web.my12306.dao.IUserDao;
import com.web.my12306.dao.impl.PrivilegeDaoImpl;
import com.web.my12306.dao.impl.UserDaoImpl;
import com.web.my12306.pojo.User;
import com.web.my12306.service.UserService;

import java.util.List;
import java.util.Set;

public class UserServiceImpl implements UserService {

    /**
     * 方艺
     * 2017.9.12
     */
    IUserDao userdao = new UserDaoImpl();
    User user = new User();
//    UserService userService = new UserServiceImpl();

    //注册用户
    @Override
    public void add(User user) {
        userdao.userAdd(user);
    }
    //用户登录方法
    public User login(String loginname, String password) {
        userdao.login(loginname,password);

        return user;

    }

    @Override
    public List<User> queryALl()
    {
        return userdao.queryALl();
    }

    @Override
    public Set<String> queryPriv()
    {
        IPrivilegeDao privilegeDao=new  PrivilegeDaoImpl();
        return privilegeDao.query(3);
    }
    //测试用
//    public static void main(String[] args) {
//        UserService userService = new UserServiceImpl();
//        User user = new User();
//        user.setLoginname("hy123");
//        user.setPassword("111");
//        user.setName("黄逸");
//        user.setSex("女");
//        user.setCardtype("二代身份证");
//        user.setCardid("3303243");
//        user.setTel("1234");
//        user.setState(1);
//        userService.add(user);
//        System.out.println(user.getLoginname()+user.getPassword()+user.getName());

//    }
}
